package com.s_recycler.adapter;

import android.view.ViewGroup;

import androidx.annotation.NonNull;

import com.s7.recycler.adapter.CompatRecyclerAdapter;
import com.s7.recycler.holder.BaseHolder;
import com.s7.recycler.holder.BaseViewHolder;
import com.s_recycler.R;

public class RefreshAdapter extends CompatRecyclerAdapter<String> {
    @NonNull
    @Override
    public BaseHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        return new BaseViewHolder(getView(parent, R.layout.load_item));
    }

    @Override
    public void onBindViewHolder(@NonNull BaseHolder holder, int position) {
        if (holder instanceof BaseViewHolder) {
            initClickListener((BaseViewHolder) holder, datas.get(position));
            ((BaseViewHolder) holder).setData(datas.get(position));
            bindData((BaseViewHolder) holder, position, datas.get(position));
        }
    }

    protected void bindData(BaseViewHolder holder, int position, String data) {
        holder.setText(R.id.text, data);
    }
}
